package viewcomponents;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.util.*;
import java.util.List;

import javax.swing.*;

import controller.Controller;

import model.turtle.Position;
import model.turtle.Turtle;
import view.Observer;

/**
 * This canvas contains a turtle canvas which displays turtle's trail
 * It also relates the input textfield with currently selected turtle canvas
 *
 */
public class SLogoCanvas extends JPanel //implements Observer
{
	//private int DEFAULT_SIZE = 600;
	private JPanel myCanvas;
	private CommandInput myCommandInput;
	private TurtleCanvas myTurtleCanvas;
	private Controller myController;

	public SLogoCanvas(Controller controller)
	{
		createCanvas(controller);
	}
	
	/**
	 * 
	 * @return selected SLogo canvas
	 */
	public JPanel getCanvas()
	{
		return myCanvas;
	}
	
	/**
	 * Create a canvas with a turtle canvas which shows turtle's trail,
	 *                  and relates the command input field to selected turtle canvas
	 * @param controller
	 */
	private void createCanvas(Controller controller)
	{		
		//setPreferredSize(new Dimension(DEFAULT_SIZE,DEFAULT_SIZE));
		myController = controller;
		myTurtleCanvas = new TurtleCanvas();
		add(myTurtleCanvas, BorderLayout.NORTH);
		
		myCommandInput = new CommandInput(myController);
		add(myCommandInput, BorderLayout.SOUTH);
		
		setVisible(true);
		
	}
	
	/**
	 * 
	 * @return currently selected turtle canvas
	 */
	public TurtleCanvas getTurtleCanvas()
	{
		return myTurtleCanvas;
	}
	
	/**
	 * 
	 * @return user command from typing
	 */
	public String getInput()
	{
		return myCommandInput.getInput();
	}
	
	/*
	public void drawMovement(int x0, int y0, int x1, int y1)
	{
		
	}
	
	public void moveTurtle(int x0, int y0, int x1, int y1)
	{
		
	}
	
	public void turnTurtle(int degree)
	{
		
	}
	
	public void toggleTurtle(boolean flag)
	{
		
	}
	
	public void reset()
	{
		
	}
	
	public void refresh()
	{
		
	}
	*/
	
}
